package com.xinan.system.curd;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.StringKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import java.sql.Timestamp;
import java.util.List;

@TableBind(tableName = "auth_org")
public class AuthOrg extends Model<AuthOrg>{
    public static final AuthOrg dao = new AuthOrg();

    //columns START
    private String ID = "id";  //唯一主键
    private String NAME = "name";  //机构名称
    private String CODE = "code";  //机构编码
    private String DESCINFO = "descinfo";  //机构描述
    private String SHORTNAME = "shortname";  //机构简称
    private String PID = "pid";  //父权限
    private String ENNAME = "enname";  //英文名字
    private String MANAGERNAME = "managername";  //负责人姓名
    private String PHONE = "phone";  //联系电话
    private String EMAIL = "email";  //电邮
    private String CONTACTNAME = "contactname";  //联系人姓名
    private String CONTACTMOBILE = "contactmobile";  //联系人手机号
    private String RMK = "rmk";  //备注
    private String OPTNAME = "optname";  //创建者
    private String OPTDATE = "optdate";  //操作时间

    public void setId(int value) {
        set(ID, value);
    }

	public int getId() {
		return get(ID);
	}
    public void setName(String value) {
        set(NAME, value);
    }

	public String getName() {
		return get(NAME);
	}
    public void setCode(String value) {
        set(CODE, value);
    }

	public String getCode() {
		return get(CODE);
	}
    public void setDescinfo(String value) {
        set(DESCINFO, value);
    }

	public String getDescinfo() {
		return get(DESCINFO);
	}
    public void setShortname(String value) {
        set(SHORTNAME, value);
    }

	public String getShortname() {
		return get(SHORTNAME);
	}
    public void setPid(long value) {
        set(PID, value);
    }

	public long getPid() {
		return get(PID);
	}
    public void setEnname(String value) {
        set(ENNAME, value);
    }

	public String getEnname() {
		return get(ENNAME);
	}
    public void setManagername(String value) {
        set(MANAGERNAME, value);
    }

	public String getManagername() {
		return get(MANAGERNAME);
	}
    public void setPhone(String value) {
        set(PHONE, value);
    }

	public String getPhone() {
		return get(PHONE);
	}
    public void setEmail(String value) {
        set(EMAIL, value);
    }

	public String getEmail() {
		return get(EMAIL);
	}
    public void setContactname(String value) {
        set(CONTACTNAME, value);
    }

	public String getContactname() {
		return get(CONTACTNAME);
	}
    public void setContactmobile(String value) {
        set(CONTACTMOBILE, value);
    }

	public String getContactmobile() {
		return get(CONTACTMOBILE);
	}
    public void setRmk(String value) {
        set(RMK, value);
    }

	public String getRmk() {
		return get(RMK);
	}
    public void setOptname(String value) {
        set(OPTNAME, value);
    }

	public String getOptname() {
		return get(OPTNAME);
	}
    public void setOptdate(Timestamp value) {
        set(OPTDATE, value);
    }

	public Timestamp getOptdate() {
		return get(OPTDATE);
	}
	//columns END

    public List<AuthOrg> findAll() {
        return find("select * from auth_org");
    }

    public static Record findbyid(int where) {
        return  Db.findById("auth_org", where, "id, name,pid");
    }

    public Page<AuthOrg> page(int pageNumber, int pageSize, String where) {
        String sqlExp = "from auth_org";
        if(StringKit.notBlank(where)){
            sqlExp += " where " + where;
        }
        return paginate(pageNumber, pageSize, "select *", sqlExp);
    }
}

